<template>
  <div>
    <article class="innerPage bookList">
      <header class="breadcrumb">
        <x-breadcrumb :path="$route.path" :title="$route.meta.breadcrumb" :startIndex="$route.meta.startIndex">
        </x-breadcrumb>
      </header>
      <section>
        <vmform class="act-form" @btn_submit="btn_submit" type="add" :fromData="fromData" @cancel="$router.back()" :cropImg="cropImg" :cropImgOne="cropImgOne"></vmform>
      </section>
    </article>
  </div>
</template>

<script>
import vmform from "../components/form.vue";
export default {
  components: {
    vmform,
  },
  props: {},
  data() {
    return {
      cropImg: 'cropImgOne1',
      cropImgOne: 'cropImgfen1',
      fromData: {
        title: "",
        author: "",
        type_id: "",
        img: '',
        pre_time: "",
        press: "",
        // isbn: '',
        intro: ''
      },
    };
  },
  computed: {},
  watch: {},
  activated() {
    if (this.$route.query.action) {
      if (this.$route.query.action != "refresh") {
        this.fromData = this.$options.data().fromData;
      }
    } else {
      this.fromData = this.$options.data().fromData;
    }
    this.setPageTabs();
  },
  mounted() { },
  methods: {
    btn_submit(e) {
      this.fromData = e;
      this.postList();
    },
    // 提交
    async postList() {
      try {
        let res = await this.request({
          url: "/admin/resourceVideoManage/add",
          method: "post",
          loading: true,
          data: this.fromData,
        });

        if (res) {
          this.$message.success("添加成功");
          let that = this;
          setTimeout(() => {
            that.pageTurnParams("videoManageList", { action: "refresh" });
          }, 2000);
        }
      } catch (err) {
        this.errorHandler(err);
      }
    },
  },
};
</script>
<style lang="scss" scoped></style>
